﻿// NFakeMail - A fake SMTP Server for software testing.
// 
// Copyright (C) 2010, João Angelo
// 
// This file is part of NFakeMail.
//
// NFakeMail is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// NFakeMail is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with NFakeMail; if not, see <http://www.gnu.org/licenses/>.

namespace NFakeMail
{
    using System.Collections.Generic;

    /// <summary>
    /// Represents an output data repository that distributes the received data to other repositories.
    /// </summary>
    /// <author> jmangelo </author>
    /// <history>
    /// ______________________________________________________________________________________
    /// History :
    /// 20100816 [+] jmangelo     Initial version
    /// ______________________________________________________________________________________
    /// </history>
    internal sealed class MultiOutputSink : OutputSink
    {
        public MultiOutputSink(params OutputSink[] sinks)
        {
            this.Sinks = new List<OutputSink>(sinks);
        }

        private List<OutputSink> Sinks { get; set; }

        public override void Write(string text)
        {
            foreach (var sink in this.Sinks)
            {
                sink.Write(text);
            }
        }

        public override void Write(FakeMailMessage message)
        {
            foreach (var sink in this.Sinks)
            {
                sink.Write(message);
            }
        }
    }
}
